{% extends "forum/base.html" %}

{% load bbcode %}

{% block title %}{% block header %}{{ post.title }}{% endblock %}{% endblock %}

{% block content %}
<p><a href="/forums/{{ post.forum.slug }}">&larr; Back to <em>{{ post.forum.name }}</em></a></p>
<table id="forum">
    <thead>
        <tr>
            <th width="25%">User</th>
            <th>Post</th>
        </tr>
    </thead>
    <tbody>
        <tr class="odd">
            <td>
                <div class="forum-poster"><a name="{{ post.id }}"> </a><strong>
                    {% if post.owner.creator_set %}<a href="/store/creator/{{ post.owner.username }}/">{{ post.owner.get_full_name }}</a>
                    {% else %}{{ post.owner.username }}{% endif %}
                    </strong> <span style="font-size: 75%"><a href="/forums/pm/{{ post.owner.username }}/">Send PM</a></span>
                </div>
                <div class="post-time">{{ post.ctime|date:"r" }}</div>
            </td>
            <td>
                <div class="post-header"><strong>{{ post.title }}</strong></div><div class="post-controls">[ 
                    <a href="/forums/{{ post.forum.slug }}/{{ post.id }}/reply?reply-to={{ post.id }}">Quote</a> | 
                    <a href="/forums/{{ post.forum.slug }}/{{ post.id }}/edit">Edit</a> | 
                    <a href="/forums/{{ post.forum.slug }}/{{ post.id }}/delete/">Delete</a> ]
                </div>
                <div class="post-body">{{ post.body|striptags|bbcode|safe }}</div>
                {% if post.mreason %}
                <div class="post-edits">
                    <p>Edited: <em>{{ post.mtime|date:"r" }}</em> by <em>{{ post.muser.username }}</em><br />
                    Reason: <em>{{ post.mreason }}</em></p>
                </div>
                {% endif %}
                <div class="post-sig">
                    {{ post.owner.forumuser.signature|striptags|bbcode|safe }}
                </div>
            </td>
        </tr>
        {% for p in post.post_set.all %}
        <tr class="{% cycle "even" "odd" %}">
            <td><div class="forum-poster"><a name="{{ p.id }}"> </a><strong>
                    {% if p.owner.creator_set %}<a href="/store/creator/{{ p.owner.username }}/">{{ p.owner.get_full_name }}</a>
                    {% else %}{{ p.owner.username }}{% endif %}
                    </strong> <span style="font-size: 75%"><a href="/forums/pm/{{ p.owner.username }}/">Send PM</a></span>
                </div>
                <div class="post-time">{{ p.ctime|date:"r" }}</div>
            </td>
            <td>
                <div class="post-header"><abbr title="In reply to {{ post.title }}"><strong>{{ p.title }}</strong></abbr></div><div class="post-controls">[ 
                    <a href="/forums/{{ post.forum.slug }}/{{ post.id }}/reply?reply-to={{ p.id }}">Quote</a> | 
                    <a href="/forums/{{ post.forum.slug }}/{{ p.id }}/edit">Edit</a> | 
                    <a href="/forums/{{ post.forum.slug }}/{{ p.id }}/delete/">Delete</a> ]
                </div>
                <div class="post-body">{{ p.body|striptags|bbcode|safe }}</div>
                {% if p.mreason %}
                <div class="post-edits">
                    <p>Edited: <em>{{ p.mtime|date:"r" }}</em> by <em>{{ p.muser.username }}</em><br />
                    Reason: <em>{{ p.mreason }}</em></p>
                </div>
                {% endif %}
                <div class="post-sig">
                    {{ p.owner.forumuser.signature|striptags|bbcode|safe }}
                </div>
            </td>
        </tr>
        {% endfor %}
    </tbody>
    <tfoot>
        <tr>
            <th colspan="2">
                <form action="/forums/{{ post.forum.slug }}/{{ post.id }}/reply/">
                    <input type="submit" value="Reply" />
                </form>
            </th>
        </tr>
    </tfoot>
</table>
{% endblock %}
